ENMTools

This package implements various tests, visualizations, and metrics for use with environmental niche models (ENMs) and species distribution models (SDMs).


Installation

At present, ENMTools is downloadable from https://github.com/danlwarren/ENMTools. There are multiple ways to download it. The easiest is to use devtools and install from GitHub.

Installing from GitHub using devtools

Run the following code from your R console:

install.packages("devtools")
library(devtools)
install_github("danlwarren/ENMTools")
library(ENMTools)

Install from zip file

A zipped version of the package is available at https://github.com/danlwarren/ENMTools/archive/master.zip. To install from the zip file, download a copy of it to your system. Once it’s finished downloading, type the following (where PATH is the path to the zip file):

install.packages("devtools")
library(devtools)
install_local("PATH")
library(ENMTools)

Interacting with ENMTools

Creating enmtools.species objects

First we’re going to load in some environmental data.

env.files <- list.files(path = "test/testdata/", pattern = "pc", full.names = TRUE)
env <- stack(env.files)
names(env) <- c("layer.1", "layer.2", "layer.3", "layer.4")
env <- setMinMax(env)

ENMTools is primarily designed to examine patterns of similarity and difference between ENMs for different species. In order to simplify interactions with the functions in ENMTools, you need to put your data for each of your species into an enmtools.species object. You can create and view an empty enmtools.species object just by typing:

ahli <- enmtools.species()
ahli
## 
## 
## Range raster not defined.
## 
## Presence points not defined.
## 
## Background points not defined.
## 
## Species name not defined.

You can add data to this object manually:

names(ahli)
## [1] "range"             "presence.points"   "background.points"
## [4] "models"            "species.name"
ahli$species.name <- "ahli"
ahli$presence.points <- read.csv("test/testdata/ahli.csv")[,3:4]
ahli$range <- background.raster.buffer(ahli$presence.points, 50000, mask = env)
ahli$background.points <- background.points.buffer(points = ahli$presence.points,
                                                   radius = 20000, n = 1000, mask = env[[1]])

ahli
## 
## 
## Range raster: 
## class       : RasterLayer 
## dimensions  : 418, 1535, 641630  (nrow, ncol, ncell)
## resolution  : 0.008333333, 0.008333333  (x, y)
## extent      : -86.90809, -74.11642, 19.80837, 23.2917  (xmin, xmax, ymin, ymax)
## coord. ref. : NA 
## data source : in memory
## names       : layer.1 
## values      : 1, 1  (min, max)
## 
## 
## 
## Presence points (first ten only): 
## 
##  Longitude   Latitude
## ----------  ---------
##   -80.0106    21.8744
##   -79.9086    21.8095
##   -79.8065    21.7631
##   -79.8251    21.8095
##   -79.8807    21.8374
##   -79.9550    21.8374
##   -80.3446    22.0136
##   -80.2983    21.9951
##   -80.1776    21.9023
##   -80.1591    21.9673
## 
## 
## Background points (first ten only): 
## 
##  Longitude   Latitude
## ----------  ---------
##  -79.98726   22.12920
##  -79.82059   21.74587
##  -80.46226   22.08754
##  -80.32059   21.96254
##  -79.67892   21.87920
##  -80.10392   21.90420
##  -79.98726   21.96254
##  -80.32059   22.16254
##  -79.80392   21.97087
##  -79.68726   21.89587
## 
## 
## Species name:  ahli

Or you can add bits of it when the object is created:

allogus <- enmtools.species(species.name = "allogus", 
                            presence.points = read.csv("test/testdata/allogus.csv")[,3:4])

allogus$range <- background.raster.buffer(allogus$presence.points, 50000, mask = env)
allogus$background.points <- background.points.buffer(points = allogus$presence.points,
                                                      radius = 20000, n = 1000, mask = env[[1]])

allogus
## 
## 
## Range raster: 
## class       : RasterLayer 
## dimensions  : 418, 1535, 641630  (nrow, ncol, ncell)
## resolution  : 0.008333333, 0.008333333  (x, y)
## extent      : -86.90809, -74.11642, 19.80837, 23.2917  (xmin, xmax, ymin, ymax)
## coord. ref. : NA 
## data source : in memory
## names       : layer.1 
## values      : 1, 1  (min, max)
## 
## 
## 
## Presence points (first ten only): 
## 
##  Longitude   Latitude
## ----------  ---------
##   -79.2527    22.2109
##   -78.7774    22.2241
##   -78.6189    22.2373
##   -78.1039    21.1809
##   -78.0247    21.1809
##   -77.9983    20.9301
##   -77.9719    21.7091
##   -77.9719    21.5507
##   -77.9323    21.6167
##   -77.9323    20.7320
## 
## 
## Background points (first ten only): 
## 
##  Longitude   Latitude
## ----------  ---------
##  -74.87892   20.43754
##  -77.07059   20.32920
##  -75.84559   20.02920
##  -78.62892   22.28754
##  -76.81226   20.75420
##  -77.22059   19.96254
##  -77.96226   21.87920
##  -76.92892   20.19587
##  -75.90392   20.77920
##  -75.55392   20.18754
## 
## 
## Species name:  allogus

Building an ENM

ENMTools contains functions to simplify the ENM construction process. Using enmtools.species objects and the correct modeling commands, we can build models very quickly. These commands are primarily wrappers to dismo model construction and projection functions, and at present are only available for GLM, Maxent, Domain, and Bioclim models. One of the nice bits about this setup is that it allows enmtools to automatically generate suitability maps, do model evaluation, and plot the marginal suitability of habitat for each variable separately.

GLM

GLMs require the user to supply a formula, an enmtools.species object, and some environmental data.

ahli.glm <- enmtools.glm(f = pres ~ layer.1 + layer.2 + layer.3 + layer.4, species = ahli, env = env, test.prop = 0.2)
## Adding environmental data to species ahli 
##  Processing presence points...
##  Processing background points...
allogus.glm <- enmtools.glm(pres ~ layer.1 + layer.2 + layer.3 + layer.4, allogus, env, test.prop = 0.2)
## Adding environmental data to species allogus 
##  Processing presence points...
##  Processing background points...
ahli.glm
## 
## 
## Formula:  presence ~ layer.1 + layer.2 + layer.3 + layer.4
## <environment: 0x7f9e738c9438>
## 
## 
## Data table (top ten lines): 
## 
##       Longitude   Latitude   layer.1   layer.2   layer.3   layer.4   presence
## ---  ----------  ---------  --------  --------  --------  --------  ---------
## 1      -80.0106    21.8744      2765      1235      1174       252          1
## 3      -79.8065    21.7631      2158      1870       983       253          1
## 5      -79.8807    21.8374      2244      1828       945       249          1
## 6      -79.9550    21.8374      2250      1766       919       235          1
## 8      -80.2983    21.9951      2214      1786       986       284          1
## 9      -80.1776    21.9023      2287      1722       992       266          1
## 10     -80.1591    21.9673      2984       965      1311       237          1
## 11     -80.1498    21.9858      3042       841      1371       221          1
## 12     -80.1220    21.9301      2898      1033      1231       242          1
## 13     -80.1776    21.9673      2914      1020      1256       237          1
## 
## 
## Model:  
## Call:
## glm(formula = f, family = "binomial", data = analysis.df[, -c(1, 
##     2)])
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -0.6344  -0.1730  -0.1113  -0.0694   3.2541  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)  
## (Intercept) 49.683426  30.398527   1.634   0.1022  
## layer.1     -0.015577   0.007906  -1.970   0.0488 *
## layer.2     -0.013274   0.008157  -1.627   0.1037  
## layer.3      0.006862   0.007378   0.930   0.3523  
## layer.4     -0.008992   0.027465  -0.327   0.7434  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 130.29  on 1011  degrees of freedom
## Residual deviance: 115.39  on 1007  degrees of freedom
## AIC: 125.39
## 
## Number of Fisher Scoring iterations: 8
## 
## 
## 
## Model fit (training data):  class          : ModelEvaluation 
## n presences    : 12 
## n absences     : 1000 
## AUC            : 0.7709583 
## cor            : 0.1132198 
## max TPR+TNR at : -4.612712 
## 
## 
## Proportion of data wittheld for model fitting:  0.2
## 
## Model fit (test data):  class          : ModelEvaluation 
## n presences    : 4 
## n absences     : 1000 
## AUC            : 0.62025 
## cor            : 0.02548682 
## max TPR+TNR at : -5.302727 
## 
## 
## Suitability:  
## class       : RasterLayer 
## dimensions  : 418, 1535, 641630  (nrow, ncol, ncell)
## resolution  : 0.008333333, 0.008333333  (x, y)
## extent      : -86.90809, -74.11642, 19.80837, 23.2917  (xmin, xmax, ymin, ymax)
## coord. ref. : NA 
## data source : in memory
## names       : layer 
## values      : 5.141626e-10, 0.9999986  (min, max)

To check out the marginal response functions, you only need to type

ahli.glm$response.plots
## $layer.1

## 
## $layer.2

## 
## $layer.3

## 
## $layer.4

Bioclim, Domain, and Maxent

The procedure for building Bioclim, Domain, and Maxent models is similar to the procedure for GLMs, with the exception that you do not need to pass a formula to the model function. Note that running Maxent models requires a bit of extra setup; see dismo documentation for details.

ahli.dm <- enmtools.dm(ahli, env, test.prop = 0.2)
ahli.bc <- enmtools.bc(ahli, env, test.prop = 0.2)
ahli.mx <- enmtools.maxent(ahli, env, test.prop = 0.2)

Metrics: breadth, correlation, and overlap

ENMTools provides a number of metrics for ENMs and for similarities between ENMs. These include measures of niche breadth, based on Levins(1968). An important caveat when interpreting these metrics is that they are driven to some (variable) extent by the availability of different combinations of environmental variables. As such they are more accurately interpreted as a measurment of the smoothness of the geographic distribution of suitability scores than as an estimate of the breadth of the fundamental niche; an orgamism with narrow fundamental niche breadth that nonetheless encompasses a set of environmental conditions that is quite common will have a high breadth when measured using ENMs, while having a low breadth in environment space.

raster.breadth(ahli.glm)
## $B1
## [1] 0.2100297
## 
## $B2
## [1] 0.8819388

ENMTools also provides metrics for measuring similarity between ENMs. These include Schoener’s D (Schoener 1968), I (Warren et al. 2008), and the Spearman rank correlation coefficient between two rasters. While D and I are commonly used in the ENM literature, they may tend to overestimate similarity between ENMs when many grid cells are of similar values (e.g., when two species prefer different habitat but the region contains a great deal of habitat that is unsuitable for both).

raster.overlap(ahli.glm, allogus.glm)
## $D
## [1] 0.4471839
## 
## $I
## [1] 0.713239
## 
## $rank.cor
## [1] 0.8283693

A new feature of the R version of ENMTools is that you can now use these same metrics in the n-dimensional space of all combinations of environmental variables, instead of restricting your measures of model similarity to those sets of conditions that appear in the training region. This is done by repeatedly drawing Latin hypercube samples from the space of all possible combinations of environmental variables given the min and max of each variable within the training region. ENMTools continues to draw samples until subsequent iterations differ by less than a specified tolerance value. Lower tolerance values result in more precise estimates of overlap, but can take much longer to calculate.

env.overlap(ahli.glm, allogus.glm, env, tolerance = .001)
## $env.D
## [1] 0.5890369
## 
## $env.I
## [1] 0.7835038
## 
## $env.cor
## [1] 0.5411551

Hypothesis testing

Niche identity or equivalency test

In this example, we will run a niche identity (also called equivalency) test, as in Warren et al. 2008. This test takes the presence points for a pair of species and randomly reassigns them to each species, then builds ENMs for these randomized occurrences. By doing this many times, we can estimate the probability distribution for ENM overlap between species under the null hypothesis that the two species’ occurrences in the environment are effectively a random draw from the same underlying distribution. Note that niche evolution is only one of many reasons why two species’ realized environmental distributions might cause departures from this null hypothesis. See Warren et al. 2014 for details.

To run an identity test, we need to decide what type of models we will build, how many replicates we will run, and (in the case of GLM) a model formula to use for empirical models and the Monte Carlo replicates. The resulting object contains the replicate models, p values, and plots of the results. Typically idenity tests are run with at least 99 replicates, but we are using a smaller number here for the sake of execution time.

NOTE: In order for models to be comparable, both empirical and pseudoreplicate models for the identity test are conducted with pseudoabsence points pooled for the two species being compared.

id.glm <- identity.test(species.1 = ahli, species.2 = allogus, env = env, type = "glm", f = presence ~ layer.1 + layer.2 + layer.3 + layer.4, nreps = 4)
id.glm
## 
## 
##  
## 
## Identity test ahli vs. allogus
## 
## Identity test p-values:
##        D        I rank.cor    env.D    env.I  env.cor 
##      0.2      0.2      0.2      0.2      0.2      0.2 
## 
## 
## Replicates:
## 
## 
##                      D           I     rank.cor       env.D       env.I      env.cor
## ----------  ----------  ----------  -----------  ----------  ----------  -----------
## empirical    0.2164128   0.4553087   -0.4635760   0.0039050   0.0272231   -0.6178540
## rep 1        0.7427495   0.9486541    0.3280459   0.5767526   0.8461749    0.5033379
## rep 2        0.7947691   0.9700986    0.4948938   0.7037595   0.9252094    0.7422408
## rep 3        0.8354046   0.9805218    0.8408323   0.7155137   0.9320005    0.8243757
## rep 4        0.6905020   0.9249651    0.7971125   0.6961325   0.9079061    0.8320388

Background or similarity test

The background or similarity test compares the overlap seen between two species’ ENMs to the overlap expected by chance if one or both species was effectively choosing habitat at random from within their broad geographic range. The purpose of this test is to correct for the availability of habitat and ask whether the observed similarity between species or populations is significantly more (or less) than expected given the available set of environments in the regions in which they occur.

NOTE: In order for models to be comparable, both empirical and pseudoreplicate models for the background test are conducted with pseudoabsence points pooled for the two species being compared.

In Warren et al. 2008, we developed this test in the context of comparing one species’ actual occurrence to the random background occurrences of the other species. This is what we call an “asymmetric” test, and in our case we did the test in both directions with the idea that we might compare the results of A vs. B background to the results of B vs. A background. This may be informative in some cases, but many people have also found this asymmetry confusing (and indeed it is often difficult to interpret). For that reason, the background test here can be conducted against a null hypothesis that is generated from “asymmetric” (species.1 vs species.2 background) or “symmetric” (species.1 background vs. species.2 background) comparisons.

Here, for instance, is a Bioclim background test using the classical asymmetric approach:

bg.bc.asym <- background.test(species.1 = ahli, species.2 = allogus, env = env, type = "bc", nreps = 4, test.type = "asymmetric" )
bg.bc.asym
## 
## 
##  
## 
## Asymmetric background test ahli vs. allogus background
## 
## background test p-values:
##        D        I rank.cor    env.D    env.I  env.cor 
##      0.2      0.2      0.2      0.2      0.2      0.2 
## 
## 
## Replicates:
## 
## 
##                      D           I    rank.cor       env.D       env.I     env.cor
## ----------  ----------  ----------  ----------  ----------  ----------  ----------
## empirical    0.1328502   0.3177390   0.0706201   0.0185665   0.1019604   0.0803273
## rep 1        0.1951805   0.3984252   0.3100897   0.0676417   0.2213396   0.1586572
## rep 2        0.1504365   0.3350210   0.1196532   0.0913890   0.2157932   0.1614293
## rep 3        0.1380161   0.3332562   0.1166780   0.0512323   0.1901598   0.1369938
## rep 4        0.1477452   0.3314444   0.1279004   0.0795872   0.2274884   0.1974818

And here is a Domain background test using the symmetric approach:

bg.dm.sym <- background.test(species.1 = ahli, species.2 = allogus, env = env, type = "dm", nreps = 4, test.type = "symmetric" )
bg.dm.sym
## 
## 
##  
## 
## Symmetric background test ahli background vs. allogus background
## 
## background test p-values:
##        D        I rank.cor    env.D    env.I  env.cor 
##      0.2      0.2      0.2      0.2      0.2      0.2 
## 
## 
## Replicates:
## 
## 
##                      D           I    rank.cor       env.D       env.I     env.cor
## ----------  ----------  ----------  ----------  ----------  ----------  ----------
## empirical    0.4929334   0.7052122   0.2916150   0.1077749   0.3114901   0.2239600
## rep 1        0.9128296   0.9853218   0.5563553   0.3989098   0.6271092   0.5510399
## rep 2        0.9327962   0.9869339   0.8503023   0.3999514   0.6310018   0.5863593
## rep 3        0.9575593   0.9973999   0.7280578   0.6313189   0.7690140   0.5982780
## rep 4        0.9267109   0.9908421   0.9356313   0.3240868   0.5620139   0.5533692

Rangebreak tests

ENMTools also allows you to perform linear, blob, and ribbon rangebreak tests as developed in Glor and Warren 2011. The linear and blob tests are two versions of a test that permit one to ask whether the geographic regions occupied by two species are more environmentally different than expected by chance. The ribbon test, meanwhile, is designed to test whether the ranges of two species are divided by a region that is relatively unsuitable to one or both forms.

For the linear and blob tests, you call them very much like you would the identity and background tests. Here’s a linear one using GLM models:

rbl.glm <- rangebreak.linear(ahli, allogus, env, type = "bc", f = pres ~ layer.1 + layer.2 + layer.3 + layer.4, nreps = 4)
## 
## Building empirical models...
## 
## Building replicate models...
## 
## Replicate 1 ...
## 
## Replicate 2 ...
## 
## Replicate 3 ...
## 
## Replicate 4 ...
rbl.glm
## 
## 
##  
## 
## Linear rangebreak test ahli vs. allogus
## 
## rangebreak test p-values:
##        D        I rank.cor    env.D    env.I  env.cor 
##      0.8      0.8      0.8      0.6      0.8      1.0 
## 
## 
## Replicates:
## 
## 
##                      D           I    rank.cor       env.D       env.I     env.cor
## ----------  ----------  ----------  ----------  ----------  ----------  ----------
## empirical    0.1328502   0.3177390   0.0706201   0.0216568   0.1219505   0.1025213
## rep 1        0.1328502   0.3177390   0.0706201   0.0205361   0.1073438   0.0843917
## rep 2        0.2082121   0.4115158   0.1022970   0.0310362   0.1287521   0.0985146
## rep 3        0.1328502   0.3177390   0.0706201   0.0167775   0.1020276   0.0854251
## rep 4        0.1328502   0.3177390   0.0706201   0.0223374   0.1170306   0.0961631

And here’s a blob test using Bioclim:

rbb.bc <- rangebreak.blob(ahli, allogus, env, type = "bc", nreps = 4)
## 
## Building empirical models...
## 
## Building replicate models...
## 
## Replicate 1 ...
## 
## Replicate 2 ...
## 
## Replicate 3 ...
## 
## Replicate 4 ...
rbb.bc
## 
## 
##  
## 
## blob rangebreak test ahli vs. allogus
## 
## rangebreak test p-values:
##        D        I rank.cor    env.D    env.I  env.cor 
##      0.8      0.8      0.8      0.2      0.2      0.2 
## 
## 
## Replicates:
## 
## 
##                      D           I     rank.cor       env.D       env.I     env.cor
## ----------  ----------  ----------  -----------  ----------  ----------  ----------
## empirical    0.1328502   0.3177390    0.0706201   0.0232907   0.1159817   0.0879863
## rep 1        0.0327940   0.1544608   -0.0172882   0.2018612   0.2858979   0.2377633
## rep 2        0.2812060   0.4986511    0.3914680   0.0516518   0.2062061   0.1341023
## rep 3        0.1328502   0.3177390    0.0706201   0.0243669   0.1201856   0.0931920
## rep 4        0.0327940   0.1544608   -0.0172882   0.2082347   0.2949181   0.2464585

If you want to access the individual replicates (for instance to see how your ranges are being split up), you can find them in the list named “replicate.models” inside your rangebreak test object.

rbl.glm$replicate.models$ahli.rep.1
## 
## 
## Data table (top ten lines): 
## 
##       Longitude   Latitude
## ---  ----------  ---------
## 7      -80.3446    22.0136
## 8      -80.2983    21.9951
## 14     -80.2148    21.9394
## 13     -80.1776    21.9673
## 11     -80.1498    21.9858
## 10     -80.1591    21.9673
## 9      -80.1776    21.9023
## 12     -80.1220    21.9301
## 15     -80.0437    21.9720
## 16     -79.9972    21.9792
## 
## 
## Model:  class    : Bioclim 
## 
## variables: layer.1 layer.2 layer.3 layer.4 
## 
## 
## presence points: 16 
##    layer.1 layer.2 layer.3 layer.4
## 1     2201    1822     978     277
## 2     2214    1786     986     284
## 3     2329    1692    1018     269
## 4     2914    1020    1256     237
## 5     3042     841    1371     221
## 6     2984     965    1311     237
## 7     2287    1722     992     266
## 8     2898    1033    1231     242
## 9     2712    1285    1126     250
## 10    2861    1150    1194     259
##   (... ...  ...)
## 
## 
## 
## Model fit (training data):  class          : ModelEvaluation 
## n presences    : 16 
## n absences     : 2000 
## AUC            : 0.7184531 
## cor            : 0.04151962 
## max TPR+TNR at : 0.0624 
## 
## 
## Proportion of data wittheld for model fitting:  0
## 
## Model fit (test data):  [1] NA
## 
## 
## Suitability:  
## class       : RasterLayer 
## dimensions  : 418, 1535, 641630  (nrow, ncol, ncell)
## resolution  : 0.008333333, 0.008333333  (x, y)
## extent      : -86.90809, -74.11642, 19.80837, 23.2917  (xmin, xmax, ymin, ymax)
## coord. ref. : NA 
## data source : in memory
## names       : layer 
## values      : 0, 0.875  (min, max)

rbl.glm$replicate.models$allogus.rep.1
## 
## 
## Data table (top ten lines): 
## 
##       Longitude   Latitude
## ---  ----------  ---------
## 17     -79.2527    22.2109
## 18     -78.7774    22.2241
## 19     -78.6189    22.2373
## 23     -77.9719    21.7091
## 25     -77.9323    21.6167
## 24     -77.9719    21.5507
## 20     -78.1039    21.1809
## 21     -78.0247    21.1809
## 22     -77.9983    20.9301
## 26     -77.9323    20.7320
## 
## 
## Model:  class    : Bioclim 
## 
## variables: layer.1 layer.2 layer.3 layer.4 
## 
## 
## presence points: 65 
##    layer.1 layer.2 layer.3 layer.4
## 1     2656    1683    1097     325
## 2     2373    1967    1067     375
## 3     2317    1980    1065     374
## 4     2394    1789     966     364
## 5     2384    1666    1017     324
## 6     2402    1708     992     325
## 7     2461    1669     846     252
## 8     2437    1684     877     264
## 9     2315    1746     907     265
## 10    2174    1811     918     267
##   (... ...  ...)
## 
## 
## 
## Model fit (training data):  class          : ModelEvaluation 
## n presences    : 65 
## n absences     : 3000 
## AUC            : 0.6162615 
## cor            : 0.04783642 
## max TPR+TNR at : 0.1383615 
## 
## 
## Proportion of data wittheld for model fitting:  0
## 
## Model fit (test data):  [1] NA
## 
## 
## Suitability:  
## class       : RasterLayer 
## dimensions  : 418, 1535, 641630  (nrow, ncol, ncell)
## resolution  : 0.008333333, 0.008333333  (x, y)
## extent      : -86.90809, -74.11642, 19.80837, 23.2917  (xmin, xmax, ymin, ymax)
## coord. ref. : NA 
## data source : in memory
## names       : layer 
## values      : 0, 0.8615385  (min, max)

For the ribbon rangebreak test, you will need one extra thing; a third enmtools.species object representing the occurrence points (for one or both species) that fall within the ribbon of putatively unsuitable habitat. In the case of these two anoles we don’t have such a ribbon, so we’ll just simulate one based on some random points.

ribbon <- enmtools.species(species.name = "ribbon")
ribbon$presence.points <- data.frame(Longitude = runif(n = 10, min = -79, max = -78.5),
                                      Latitude = runif(n = 10, min = 21.7, max = 22.1))
plot(env[[1]])
points(ribbon$presence.points, pch = 16)

ribbon$range <- background.raster.buffer(ribbon$presence.points, 20000, mask = env)
ribbon
## 
## 
## Range raster: 
## class       : RasterLayer 
## dimensions  : 418, 1535, 641630  (nrow, ncol, ncell)
## resolution  : 0.008333333, 0.008333333  (x, y)
## extent      : -86.90809, -74.11642, 19.80837, 23.2917  (xmin, xmax, ymin, ymax)
## coord. ref. : NA 
## data source : in memory
## names       : layer.1 
## values      : 1, 1  (min, max)
## 
## 
## 
## Presence points (first ten only): 
## 
##  Longitude   Latitude
## ----------  ---------
##  -78.50995   22.06883
##  -78.96801   21.72659
##  -78.99459   21.96886
##  -78.94984   22.07980
##  -78.97400   21.87756
##  -78.64874   21.76252
##  -78.70271   21.81566
##  -78.55840   21.93328
##  -78.57016   21.95565
##  -78.52234   21.76406
## 
## 
## Background points not defined.
## 
## Species name:  ribbon

Now we’ll run a ribbon rangebreak test using Domain models. We also need to tell it the width of the ribbons to generate for the replicates. The units for the width argument are the same units that the presence points are in; e.g., if the points are in decimal degrees you should supply the width of the barrier in decimal degrees.

rbr.dm <- rangebreak.ribbon(ahli, allogus, ribbon, env, type = "dm", width = 0.5, nreps = 4)
## 
## 
## No background points provided, drawing background from range raster.
## Warning in couldBeLonLat(mask): CRS is NA. Assuming it is longitude/
## latitude
## 
## Building empirical models...
## 
## Building replicate models...
## 
## Replicate 1 ...
## 
## Replicate 2 ...
## 
## Replicate 3 ...
## 
## Replicate 3 ...
## 
## Replicate 3 ...
## 
## Replicate 3 ...
## 
## Replicate 4 ...
rbr.dm
## 
## 
##  
## 
## ribbon rangebreak test ahli vs. allogus
## 
## rangebreak test p-values...
## 
## Species 1 vs. Species 2:
##        D        I rank.cor    env.D    env.I  env.cor 
##      0.2      0.2      0.8      0.2      0.2      0.2 
## 
## Species 1 vs. Ribbon:
##        D        I rank.cor    env.D    env.I  env.cor 
##      0.6      0.4      0.4      0.4      0.4      0.4 
## 
## Species 2 vs. Ribbon:
##        D        I rank.cor    env.D    env.I  env.cor 
##      0.4      0.4      0.2       NA       NA       NA 
## 
## Outside vs. Ribbon:
##        D        I rank.cor    env.D    env.I  env.cor 
##      0.4      0.4      0.2       NA       NA       NA 
## 
## 
## Replicates:
## 
## Species 1 vs. Species 2:
##                   D         I   rank.cor     env.D     env.I   env.cor
## empirical 0.4929334 0.7052122 0.29161498 0.1046497 0.3075381 0.2181804
## rep 1     0.7152380 0.8912226 0.32949475 0.1345036 0.3512988 0.3204399
## rep 2     0.8182518 0.9628822 0.06746442 0.4764703 0.6486836 0.3988869
## rep 3     0.5178966 0.7254688 0.28362381 0.1258995 0.3390166 0.2375990
## rep 4     0.8046292 0.9359254 0.17579880 0.2233468 0.4591233 0.3402720
## 
## Species 1 vs. Ribbon:
##                   D         I  rank.cor       env.D      env.I    env.cor
## empirical 0.2767713 0.4249489 0.1842350 0.009563305 0.06415594 0.04735109
## rep 1     0.7210396 0.8935014 0.3590865 0.247368689 0.40975284 0.30744911
## rep 2     0.2288747 0.4547475 0.0718088 0.011971408 0.09460803 0.04843157
## rep 3     0.6188173 0.7684687 0.4737759 0.225944302 0.34874016 0.26166401
## rep 4     0.1266842 0.3358246 0.2438241 0.001886805 0.04320838 0.02866385
## 
## Species 2 vs. Ribbon:
##                   D         I   rank.cor       env.D      env.I    env.cor
## empirical 0.2287107 0.4612954 -0.2371638 0.001253972 0.03232012 0.03311244
## rep 1     0.9139145 0.9878635  0.7929080 0.337893433 0.57369612 0.52767558
## rep 2     0.2419735 0.4728217  0.3527807 0.050605066 0.20856167 0.17175467
## rep 3     0.7278454 0.8950365  0.1805804 0.067000738 0.24269209 0.25291465
## rep 4     0.1001006 0.2983785  0.2292359          NA         NA         NA
## 
## Outside vs. Ribbon:
##                    D         I   rank.cor       env.D      env.I   env.cor
## empirical 0.22968129 0.4624150 -0.2425731 0.001090931 0.03088669 0.0330785
## rep 1     0.91745142 0.9879689  0.8107877 0.332992213 0.56815637 0.5000695
## rep 2     0.24638927 0.4779141  0.6379463 0.021519805 0.13582210 0.1502182
## rep 3     0.72931126 0.8962080  0.2137343 0.062846635 0.23427274 0.2504953
## rep 4     0.09927263 0.2970406  0.2436503          NA         NA        NA

## Warning: Removed 1 rows containing non-finite values (stat_density).
## Warning: Removed 1 rows containing non-finite values (stat_density).

## Warning: Removed 1 rows containing non-finite values (stat_density).

## Warning: Removed 1 rows containing non-finite values (stat_density).

## Warning: Removed 1 rows containing non-finite values (stat_density).

## Warning: Removed 1 rows containing non-finite values (stat_density).

Note that the output table here has slope, intercept, and intercept offset.

rbr.dm$lines.df
##         slope  intercept    offset
## 1 -0.06545754   15.88132 0.2505350
## 2 -2.46553085 -167.81478 0.6651523
## 3 -1.06081423  -61.15456 0.3644625
## 4  0.61367657   68.67107 0.2933214

The intercept denotes the intercept corresponding to the CENTER of the ribbon. To get the lines denoting the edges of the ribbons (for example if you want to plot the ribbons on a map), you add and substract the offset. In other words, the top edge of the ribbon is given by y = (slope * x) + intercept + offset, while the bottom edge is given by y = (slope * x) + intercept - offset.

Literature cited

Levins, R. 1968. Evolution In Changing Environments. Monographs in Population Biology, volume 2. Princeton University Press, Princeton, New Jersey, USA.

Schoener, T. W. 1968. Anolis lizards of Bimini: resource partitioning in a complex fauna. Ecology 49:704- 726.

Warren, D.L., R.E. Glor, and M. Turelli. 2008. Environmental niche identity versus conservatism: quantitative approaches to niche evolution. Evolution 62:2868-2883. doi: 10.1111/j.1558-5646.2008.00482.x

Warren, D.L., M. Cardillo, D.F. Rosauer, and D.I. Bolnick. 2014. Mistaking geography for biology: inferring processes from species distributions. Trends in Ecology and Evolution 29 (10), 572-580. doi: 10.1016/j.tree.2014.08.003